import datetime
import turtle
#主程序
def main():
    turtle.setup(800,400,400,200)
    turtle.pensize(5)
    turtle.penup()
    turtle.backward(250)
    turtle.pendown()
    turtle.speed(10)
    turtle.pencolor("red")
    time = datetime.datetime.now().strftime("%Y%m%d")
    drawDate(time)
#绘制时间
def drawDate(date):
    x = 1
    for i in date:
        drawDigit(i)
        x+=1
        if(x==5):
            turtle.write('年',font=("Arial",  18,  "normal"))
            turtle.penup()
            turtle.fd(38)
            turtle.pencolor("green")
        if(x==7):
            turtle.write('月',font=("Arial",  18,  "normal"))
            turtle.penup()
            turtle.fd(38)
            turtle.pencolor("blue")
        if(x==9):
            turtle.write('日',font=("Arial",  18,  "normal"))

#绘画数字
def drawDigit(num):
    print(num)
    drawLine(True) if int(num) in [2,3,4,5,6,8,9] else drawLine(False)
    drawLine(True) if int(num) in [0,1,3,4,5,6,7,8,9] else drawLine(False)
    drawLine(True) if int(num) in [0,2,3,5,6,8,9] else drawLine(False)
    drawLine(True) if int(num) in [0,2,6,8] else drawLine(False)
    turtle.left(90)
    drawLine(True) if int(num) in [0,4,5,6,8,9] else drawLine(False)
    drawLine(True) if int(num) in [0,2,3,5,6,7,8,9] else drawLine(False)
    drawLine(True) if int(num) in [0,1,2,3,4,7,8,9] else drawLine(False)
    turtle.left(180)
    turtle.penup()
    turtle.fd(20)
#绘画一笔
def drawLine(line):
    print(line)
    if(line):
        turtle.pendown()
    else:
        turtle.penup()
    turtle.fd(40)
    turtle.right(90)
main()
